package TopK;
import java.util.Vector;

import Basics.*;

public class DerivationTree implements Comparable<DerivationTree>
{
	Atom derivedFact;
	
	Vector<Atom> factPointers = new Vector<Atom>();
	
	Rule rulePointer;
	
	Vector<DerivationTree> children = new Vector<DerivationTree>(); 
	
	Vector<DerivationTree> parents = new Vector<DerivationTree>(); 
	
	double weight;
	
	
	
	public Vector<DerivationTree> getChildren() 
	{
		return children;
	}

	public Vector<DerivationTree> getParents() 
	{
		return parents;
	}

	public void setParents(Vector<DerivationTree> parents) 
	{
		this.parents = parents;
	}
	
	public void addParent(DerivationTree parent) 
	{
		this.parents.add(parent);
	}

	public void setChildren(Vector<DerivationTree> children) 
	{
		this.children = children;
	}
	
	public void addChild(DerivationTree child) 
	{
		this.children.add(child);
	}

	public Atom getDerivedFact() 
	{
		return derivedFact;
	}

	public void setDerivedFact(Atom derivedFact) 
	{
		this.derivedFact = derivedFact;
	}
	
	public Vector<Atom> getFactPointers() 
	{
		return factPointers;
	}
	
	public void setFactPointers(Vector<Atom> factPointers) 
	{
		this.factPointers = factPointers;
	}
	
	public void addFactPointer(Atom factPointer) 
	{
		this.factPointers.add(factPointer);
	}
	
	public Rule getRulePointer() 
	{
		return rulePointer;
	}
	
	public void setRulePointer(Rule rulePointer) 
	{
		this.rulePointer = rulePointer;
	}
	
	public double getWeight() 
	{
		return weight;
	}
	
	public void setWeight(double weight) 
	{
		this.weight = weight;
	}

	public int compareTo(DerivationTree other) 
	{
		double w1= weight;
		double w2= other.getWeight();
	    int retVal;
	    if (w1 == w2) { retVal = 0; }	    	
	    else if (w1 > w2) { retVal = -1; }
	    else {retVal = 1;}
	    return retVal;
	}
	
	
}
